<html>
<head><meta charset="utf-8"><title>turning on integer overflow checking when building rustc · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html">turning on integer overflow checking when building rustc</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="234606737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234606737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Renshaw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234606737">(Apr 15 2021 at 02:26)</a>:</h4>
<p>How do I build a <code>rustc</code> that has integer overflow checking enabled?<br>
I tried setting <code>debug=true</code> in my <code>config.toml</code>, but that doesn't seem to do it.</p>



<a name="234607274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234607274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Renshaw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234607274">(Apr 15 2021 at 02:34)</a>:</h4>
<p>I have this code:</p>
<div class="codehilite"><pre><span></span><code>        if self.err_count() &lt; old_count {
            dbg!(self.err_count());
            dbg!(old_count);
        } else {
            dbg!(&quot;it&#39;s fine&quot;);
        }
        let errors = self.err_count() - old_count;
        dbg!(errors);
</code></pre></div>
<p>and it's outputting this:</p>
<div class="codehilite"><pre><span></span><code>[compiler/rustc_session/src/session.rs:478] self.err_count() = 12
[compiler/rustc_session/src/session.rs:479] old_count = 13
[compiler/rustc_session/src/session.rs:484] errors = 18446744073709551615
</code></pre></div>
<p>but I expect it to panic, because I have debug assertions enabled.</p>



<a name="234607313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234607313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234607313">(Apr 15 2021 at 02:34)</a>:</h4>
<p><span class="user-mention" data-user-id="258831">@David Renshaw</span> if you set <code>debug-assertions = true</code>, does that change anything?</p>



<a name="234607331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234607331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Renshaw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234607331">(Apr 15 2021 at 02:35)</a>:</h4>
<p>I'm already doing that</p>



<a name="234607355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234607355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Renshaw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234607355">(Apr 15 2021 at 02:35)</a>:</h4>
<p><code>debug = true</code> and <code>debug-assertions = true</code></p>



<a name="234607364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234607364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234607364">(Apr 15 2021 at 02:35)</a>:</h4>
<p>hmm I'm not sure then</p>



<a name="234607431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234607431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Renshaw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234607431">(Apr 15 2021 at 02:36)</a>:</h4>
<p>I'm only building stage 1. Could that have anything to do with it?</p>



<a name="234607439"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234607439" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234607439">(Apr 15 2021 at 02:36)</a>:</h4>
<p>I wouldn't expect that to be related, no</p>



<a name="234607452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234607452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Renshaw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234607452">(Apr 15 2021 at 02:36)</a>:</h4>
<p>(I did verify that <code>debug_assert!(false)</code> does indeed panic.)</p>



<a name="234607460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234607460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234607460">(Apr 15 2021 at 02:37)</a>:</h4>
<p>rustbuild uses <code>--release</code> almost always - maybe it forgets to turn wrapping arithmetic back off?</p>



<a name="234607832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234607832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234607832">(Apr 15 2021 at 02:42)</a>:</h4>
<p><code>overflow-checks</code> are normally a separate flag from <code>debug-assertions</code></p>



<a name="234608647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234608647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Renshaw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234608647">(Apr 15 2021 at 02:54)</a>:</h4>
<div class="codehilite"><pre><span></span><code>failed to parse TOML configuration &#39;config.toml&#39;: unknown field `overflow-checks`, expected one of `optimize`, `debug`, `codegen-units`, `codegen-units-std`, `debug-assertions`, `debug-assertions-std`, `debug-logging`, `debuginfo-level`, `debuginfo-level-rustc`, `debuginfo-level-std`, `debuginfo-level-tools`, `debuginfo-level-tests`, `run-dsymutil`, `backtrace`, `incremental`, `parallel-compiler`, `default-linker`, `channel`, `description`, `musl-root`, `rpath`, `verbose-tests`, `optimize-tests`, `codegen-tests`, `ignore-git`, `dist-src`, `save-toolstates`, `codegen-backends`, `lld`, `use-lld`, `llvm-tools`, `deny-warnings`, `backtrace-on-ice`, `verify-llvm-ir`, `thin-lto-import-instr-limit`, `remap-debuginfo`, `jemalloc`, `test-compare-mode`, `llvm-libunwind`, `control-flow-guard`, `new-symbol-mangling`, `profile-generate`, `profile-use`, `download-rustc` for key `rust` at line 667 column 1
</code></pre></div>



<a name="234608658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234608658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234608658">(Apr 15 2021 at 02:55)</a>:</h4>
<p>overflow checks cannot be turned on with the config.</p>



<a name="234608669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234608669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Renshaw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234608669">(Apr 15 2021 at 02:55)</a>:</h4>
<p>how can they be turned on?</p>



<a name="234608670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234608670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234608670">(Apr 15 2021 at 02:55)</a>:</h4>
<p>You have to set it in Cargo.toml (or environment variable)</p>



<a name="234608686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234608686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234608686">(Apr 15 2021 at 02:55)</a>:</h4>
<p>It was detected just recently that some tests will fail: <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/Test.20failures.20with.20.60overflow-checks.20.3D.20true.60/near/233977266">https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Test.20failures.20with.20.60overflow-checks.20.3D.20true.60/near/233977266</a></p>



<a name="234608751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234608751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234608751">(Apr 15 2021 at 02:56)</a>:</h4>
<p>I don't think anyone ever tests it with rustc, and it isn't tested on CI, so it might be a bumpy road if you try.</p>



<a name="234608787"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234608787" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Renshaw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234608787">(Apr 15 2021 at 02:57)</a>:</h4>
<p>heh, yep, that's the same overflow I'm hitting</p>



<a name="234608866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234608866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Renshaw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234608866">(Apr 15 2021 at 02:58)</a>:</h4>
<p>it happens on this tiny program:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">const</span><span class="w"> </span><span class="n">M</span><span class="p">;</span><span class="w"></span>
</code></pre></div>



<a name="234608954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234608954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234608954">(Apr 15 2021 at 02:59)</a>:</h4>
<p>In <code>track_errors</code>?  I have no idea what that function does. Might be worth investigating it.</p>



<a name="234609014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234609014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234609014">(Apr 15 2021 at 03:00)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120518">Eric Huss</span> <a href="#narrow/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc/near/234608954">said</a>:</p>
<blockquote>
<p>In <code>track_errors</code>?  I have no idea what that function does. Might be worth investigating it.</p>
</blockquote>
<p>I think it's used to count the number of errors for <code>-Ztreat-err-as-bug</code></p>



<a name="234609022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234609022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Renshaw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234609022">(Apr 15 2021 at 03:00)</a>:</h4>
<p>I was hoping to bisect the overflow</p>



<a name="234609046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234609046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Renshaw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234609046">(Apr 15 2021 at 03:00)</a>:</h4>
<p>but first I need to be able to actually make it happen (outside of my fuzzing setup)</p>



<a name="234609089"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234609089" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234609089">(Apr 15 2021 at 03:00)</a>:</h4>
<p>ahhh I knew I'd seen you before <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> you run the rustc fuzzer</p>



<a name="234610147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234610147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Renshaw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234610147">(Apr 15 2021 at 03:14)</a>:</h4>
<p>aha, this seems to have done it:</p>
<div class="codehilite"><pre><span></span><code>RUSTFLAGS=&quot;-C overflow-checks=on&quot; ./x.py build --stage 1
</code></pre></div>



<a name="234613895"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234613895" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234613895">(Apr 15 2021 at 04:04)</a>:</h4>
<p>It seems like a lot of this code dealing with "were errors generated" doesn't handle stashed diagnostics correctly, since those can come and go at various times.   (It's failing because an error gets stashed, and then stolen.)  The comment <code>Remove this method, it should never be needed.</code> isn't really clear why it shouldn't be needed.</p>



<a name="234664362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234664362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Renshaw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234664362">(Apr 15 2021 at 12:17)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/issues/84219">https://github.com/rust-lang/rust/issues/84219</a></p>



<a name="234664393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234664393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Renshaw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234664393">(Apr 15 2021 at 12:17)</a>:</h4>
<p>^ I wrote up a bug report</p>



<a name="234667613"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234667613" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hyd-dev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234667613">(Apr 15 2021 at 12:42)</a>:</h4>
<p>I'm curious, why the issue title states the panic location is at line 478, the issue description states it at line 475, and it's at line 477 on my machine...</p>



<a name="234668063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234668063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hyd-dev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234668063">(Apr 15 2021 at 12:45)</a>:</h4>
<p>Oh I see, it's at line 475 in 1.51.0.</p>



<a name="234668330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234668330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hyd-dev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234668330">(Apr 15 2021 at 12:47)</a>:</h4>
<p>I assume line 478 is due to some <code>dbg!</code>s.</p>



<a name="234669352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234669352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Renshaw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234669352">(Apr 15 2021 at 12:55)</a>:</h4>
<p>The error message I reported in the issue is from when I ran it at exactly the regressing commit</p>



<a name="234694551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234694551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234694551">(Apr 15 2021 at 15:09)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120518">Eric Huss</span> <a href="#narrow/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc/near/234608658">said</a>:</p>
<blockquote>
<p>overflow checks cannot be turned on with the config.</p>
</blockquote>
<p>This sounds like a bug in rustbuild to me. At the very least, I would expect <code>debug = true</code> to include overflow checks.</p>



<a name="234698615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234698615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234698615">(Apr 15 2021 at 15:31)</a>:</h4>
<p>Hm, I think I find that surprising; debug = true isn't the same as profile = dev in cargo</p>



<a name="234698647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234698647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234698647">(Apr 15 2021 at 15:31)</a>:</h4>
<p>(maybe it should be)</p>



<a name="234698688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234698688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234698688">(Apr 15 2021 at 15:31)</a>:</h4>
<p>but we don't e.g. turn incremental on with debug = true either.</p>



<a name="234702717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234702717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234702717">(Apr 15 2021 at 15:52)</a>:</h4>
<p>yea, my suggestion earlier was to turn on overflow checks if debug-assertions are enabled.  I don't know what kind of performance hit that would be, though.  (And of course the existing bugs will need to be fixed first.)  IIUC, debug-assertions are enabled on all builders except macos.</p>



<a name="234711072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234711072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234711072">(Apr 15 2021 at 16:41)</a>:</h4>
<p>That seems not unreasonable, but I'd want to make sure we match the behavior in Cargo - does turning debug-assertions on there turn on overflow-checks as well? Otherwise, even though it seems reasonable, it feels confusing to not match.</p>



<a name="234711184"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234711184" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234711184">(Apr 15 2021 at 16:41)</a>:</h4>
<p>I don't think debug-assertions are the right comparison, I think this should be part of <code>debug = true</code></p>



<a name="234711279"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234711279" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234711279">(Apr 15 2021 at 16:42)</a>:</h4>
<p>cargo treats debug-assertions and overflow-checks independently <a href="https://doc.rust-lang.org/cargo/reference/profiles.html">https://doc.rust-lang.org/cargo/reference/profiles.html</a></p>



<a name="234711387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234711387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234711387">(Apr 15 2021 at 16:43)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc/near/234711184">said</a>:</p>
<blockquote>
<p>I don't think debug-assertions are the right comparison, I think this should be part of <code>debug = true</code></p>
</blockquote>
<p>(and we could always add an independent toggle for it, the same way there's a toggle for specifically debug-assertions)</p>



<a name="234711776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234711776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234711776">(Apr 15 2021 at 16:45)</a>:</h4>
<p>in rustc debug assertions change the default for overflow checks</p>



<a name="234712451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234712451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234712451">(Apr 15 2021 at 16:49)</a>:</h4>
<p><span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span> I don't feel strongly either way. I do think <code>debug = true</code> likely is confusing in terms of affecting a lot more than someone might intend.</p>



<a name="234712624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234712624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234712624">(Apr 15 2021 at 16:50)</a>:</h4>
<p>I think <code>debug</code> should be a profile setting, the same way <code>--release</code> and <code>--debug</code> are profile settings. If you want to change something specific, you can update one of the more granular settings, like debug-assertions or debug-info.</p>



<a name="234732146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234732146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Renshaw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234732146">(Apr 15 2021 at 18:52)</a>:</h4>
<p>What confused me is that this is sufficient to enable overflow checking when I run fuzzing: <a href="https://github.com/dwrensha/fuzz-rustc/blob/425385b14457aede0a009c89a4b80744b37bc342/run-fuzzer.sh#L25">https://github.com/dwrensha/fuzz-rustc/blob/425385b14457aede0a009c89a4b80744b37bc342/run-fuzzer.sh#L25</a></p>
<div class="codehilite"><pre><span></span><code>export RUSTFLAGS=&quot;$RUSTFLAGS -C debug-assertions=on&quot;
</code></pre></div>



<a name="234732231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234732231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234732231">(Apr 15 2021 at 18:53)</a>:</h4>
<p>well yes, because that skips cargo and x.py altogether and passes it straight to the compiler</p>



<a name="234732346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234732346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Renshaw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234732346">(Apr 15 2021 at 18:54)</a>:</h4>
<p>so when I saw <code>debug-assertions</code> in <code>config.toml</code>, I expected it to do the same thing</p>



<a name="234732488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234732488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> David Renshaw <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234732488">(Apr 15 2021 at 18:55)</a>:</h4>
<p>(The fuzzer script does use <code>cargo</code>, but it does not use <code>x.py</code>.)</p>



<a name="234732553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234732553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234732553">(Apr 15 2021 at 18:55)</a>:</h4>
<p>oh oh I see I misread</p>



<a name="234732563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234732563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234732563">(Apr 15 2021 at 18:55)</a>:</h4>
<p>yeah I'm not sure</p>



<a name="234800415"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234800415" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234800415">(Apr 16 2021 at 06:23)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc/near/234711072">said</a>:</p>
<blockquote>
<p>I'd want to make sure we match the behavior in Cargo - does turning debug-assertions on there turn on overflow-checks as well? Otherwise, even though it seems reasonable, it feels confusing to not match.</p>
</blockquote>
<p>in cargo, <code>debug-assertions</code> and <code>overflow-checks</code> are totally independent. By default they always match each other in all four profiles, but you can set them individually.</p>



<a name="234897845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234897845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234897845">(Apr 16 2021 at 18:09)</a>:</h4>
<p>sounds to me like we could just add <code>overflow-checks</code> to the <code>x.py</code> config.toml. Is this even worthy of an MCP ?</p>



<a name="234897874"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234897874" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234897874">(Apr 16 2021 at 18:09)</a>:</h4>
<p>(it sounds like an oversight, if anything, in our <code>debug=true</code> coverage)</p>



<a name="234904424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/turning%20on%20integer%20overflow%20checking%20when%20building%20rustc/near/234904424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/turning.20on.20integer.20overflow.20checking.20when.20building.20rustc.html#234904424">(Apr 16 2021 at 18:59)</a>:</h4>
<p>I would just make this change and see how much it affects performance:</p>
<div class="codehilite" data-code-language="Diff"><pre><span></span><code><span class="gh">diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs</span>
<span class="gh">index 38901a35296..986945f63bb 100644</span>
<span class="gd">--- a/src/bootstrap/builder.rs</span>
<span class="gi">+++ b/src/bootstrap/builder.rs</span>
<span class="gu">@@ -1140,14 +1140,13 @@ pub fn cargo(</span>
             }
         };
         cargo.env(profile_var("DEBUG"), debuginfo_level.to_string());
<span class="gd">-        cargo.env(</span>
<span class="gd">-            profile_var("DEBUG_ASSERTIONS"),</span>
<span class="gd">-            if mode == Mode::Std {</span>
<span class="gd">-                self.config.rust_debug_assertions_std.to_string()</span>
<span class="gd">-            } else {</span>
<span class="gd">-                self.config.rust_debug_assertions.to_string()</span>
<span class="gd">-            },</span>
<span class="gd">-        );</span>
<span class="gi">+        let debug_assert = if mode == Mode::Std {</span>
<span class="gi">+            self.config.rust_debug_assertions_std.to_string()</span>
<span class="gi">+        } else {</span>
<span class="gi">+            self.config.rust_debug_assertions.to_string()</span>
<span class="gi">+        };</span>
<span class="gi">+        cargo.env(profile_var("DEBUG_ASSERTIONS"), &amp;debug_assert);</span>
<span class="gi">+        cargo.env(profile_var("OVERFLOW_CHECKS"), &amp;debug_assert);</span>

         // `dsymutil` adds time to builds on Apple platforms for no clear benefit, and also makes
         // it more difficult for debuggers to find debug info. The compiler currently defaults to
</code></pre></div>
<p>Do you see situations where it would be necessary to control it independently?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>